//
//  DBLaunchScrollViewController.m
//  DianBa
//
//  Created by karl on 2018/8/20.
//  Copyright © 2018年 DianBa. All rights reserved.
//

#import "DBLaunchScrollViewController.h"

@interface DBLaunchScrollViewController ()

@end

@implementation DBLaunchScrollViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [scrollView setContentSize:CGSizeMake(SCREEN_WIDTH * 3, SCREEN_HEIGHT)];
    [scrollView setShowsVerticalScrollIndicator:NO];
    [scrollView setShowsHorizontalScrollIndicator:NO];
    [scrollView setPagingEnabled:YES];
    [self.view addSubview:scrollView];
    
    for (int ii = 0; ii < 3; ii ++) {
        NSString *imageName = [NSString stringWithFormat:@"%d_%d_%d",(int)SCREEN_WIDTH,(int)SCREEN_HEIGHT,ii + 1];
        
        UIImageView *launchImageView = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH * ii, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        [launchImageView setImage:[UIImage imageNamed:imageName]];
        [launchImageView setUserInteractionEnabled:YES];
        [scrollView addSubview:launchImageView];
        
        if (ii == 2) {
            UIButton *enterButton = [UIButton buttonWithType:UIButtonTypeCustom];
            [enterButton setFrame:CGRectMake(0, SCREEN_HEIGHT - Adapt(110), SCREEN_WIDTH, Adapt(50))];
            [enterButton addTarget:self action:@selector(enterButtonClick) forControlEvents:UIControlEventTouchUpInside];
            [enterButton setBackgroundColor:[UIColor blueColor]];
            [launchImageView addSubview:enterButton];
        }
    }
}

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

-(void)enterButtonClick{
    if (self.delegate && [self.delegate respondsToSelector:@selector(launchEnterHomeViewController)]) {
        [[NSUserDefaults standardUserDefaults]setObject:@"yes" forKey:FRIST_LOGIN];
        [self.delegate launchEnterHomeViewController];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
